<?php
	ob_start();
	session_start();
	require("librarys/funcs/Manager.php");
	require("librarys/funcs/Utils.php");

	$conn = new Connection();
	$util = new Utils();

	$catalog_id = $_GET['c'];

	$catalog = $conn->get_all_data($table = 'catalog', $catalog_id);

	if ($catalog == "")
		$util->redirect("index.php");
	$table    = "product";
	$pageSize = 30;
	$pageNum  = 1;
	if (isset($_GET['pageNum']) == true)
		$pageNum = $_GET['pageNum'];
	else
		$pageNum = 1;
	$startRow  = ($pageNum - 1) * $pageSize;
	$endRow    = $startRow + $pageSize;
	$totalRows = $conn->get_maxrow_of_table($table);

	$list_new_product = $conn->get_all_data_fix($table, -1, 1, $option1, $option2 = ' AND catalog_id = ' . $catalog['id'] . ' ORDER BY created DESC LIMIT ' . $startRow . ',' . $pageSize . '');
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>

    <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>

    <title><?=$catalog['title']  ?> - Vnaloha Shop</title>
    <meta name="description" content="<?=$catalog['title']  ?> - Vnaloha Shop"/>
    <meta name="keyword" content="<?=$catalog['title']  ?> - Vnaloha Shop"/>
    <meta name="author" content="hieudoan"/>

	<?php include_once 'gg.php' ?>
</head>

<body>
<? include_once 'nav.php' ?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span2">
			<? include_once 'menu.php' ?>
        </div>
        <div class="span10">
            <div class="page-header">
                <h2><?=$catalog1['title']  ?></h2>
            </div>
            <ul class="thumbnails">
				<?php foreach ($list_new_product as $key => $value): ?>
                <li class="span2 <?=($key) % 6 == 0 ? "ml-none" : ""  ?>">
                    <div class="thumbnail product-item">
                        <a title="<?=$value['title']  ?>"
                           href="product.php?c=<?=$value['catalog1_id']  ?>&id=<?=$value['id']  ?>">
                            <img alt="<?=$value['title']  ?>"
                                 src="<?=$conn->BASE_URL  ?>uploads/gallery/<?=$value['url_image']  ?>"/>
                        </a>

                        <div class="caption">
                            <a title="<?=$value['title']  ?>"
                               href="product.php?c=<?=$value['catalog1_id']  ?>&id=<?=$value['id']  ?>">
                                <h5><?=$value['title']  ?></h5>
                            </a>
                        </div>
                    </div>
                </li>
				<?php endforeach ?>
            </ul>
            <div class="pagination">
                <ul class="pull-right">
					<?php echo $conn->pageList($totalRows, $pageNum, $pageSize); ?>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>
</html>
